package java9;

import java.util.Scanner;

public class Q5_4 {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		Student stu = new Student();
		while (in.hasNext()) {
			String str = in.next();
			if (str.equals("new")) {
				try {
					stu.setName(in.next());
					stu.addScore(in.nextInt());
					System.out.println(stu.toString());
				} catch (Exception e) {
					System.out.println(e);
				}
			} else {
				in.close();
				System.out.println("scanner closed");
				break;
			}

		}

	}
}

@SuppressWarnings("serial")
class IllegalScoreException extends Exception {
	public IllegalScoreException(String s) {
		super(s);
	}
}

@SuppressWarnings("serial")
class IllegalNameException extends Exception {
	public IllegalNameException(String s) {
		super(s);
	}
}

class Student {
	private String name;
	private int score;

	public String getName() {
		return name;
	}

	public void setName(String name) throws IllegalNameException {
		if (Character.isDigit(name.charAt(0))) {
			throw new IllegalNameException("the first char of name must not be digit, name=" + name);
		} else {
			this.name = name;
		}

	}

	public int getScore() {
		return score;
	}

	public void setScore(int score) {
		this.score = score;
	}

	@Override
	public String toString() {
		return "Student [name=" + name + ", score=" + score + "]";
	}

	public int addScore(int score) throws IllegalScoreException {
		this.score = score;
		if (score < 0 || score > 100) {
			this.score--;
			throw new IllegalScoreException("score out of range, score=" + score);
		}

		return score;
	}
}